//
//  qryFriendVC.m
//  SelfDriving
//
//  Created by apple on 16/7/2.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "qryFriendVC.h"
#import "MsgCell.h"
#import "FriendDetailsMainVC.h"
@interface qryFriendVC ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *table;

@end

@implementation qryFriendVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"搜索结果";
    if(_ary.count==0){
        UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, SCRE_HEIGHT/2 - 20,SCRE_WIDTH, 40)];
        lable.text = @"暂无数据";
        lable.textColor = [UIColor grayColor];
        lable.textAlignment = NSTextAlignmentCenter;
        [self.view addSubview:lable];
        _table.hidden = YES;
    }
}

#pragma mark 返回分组数
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
#pragma mark 返回每组行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _ary.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 8;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70;
}
#pragma mark返回每行的单元格
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    LoginResponseModel *contact = [_ary objectAtIndex:indexPath.row];
    MsgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MsgCell"];
    cell.img.layer.cornerRadius = cell.img.frame.size.width/2;
    cell.img.clipsToBounds = YES;
    cell.name.text = contact.nickname;
    [ValidateHelper setImage:contact.headsmall img:cell.img istoux:YES];
    cell.job.text = [NSString stringWithFormat:@"%@岁", [ValidateHelper timeToAge:contact.age]];
    cell.content.text = contact.sign;
    cell.cbtn.layer.borderColor = colorBG.CGColor;
    cell.cbtn.layer.borderWidth = 0.8;
    cell.cbtn.layer.cornerRadius = 4;
    cell.cbtn.tag = [contact.uid intValue];
    cell.cbtn.hidden = YES;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    LoginResponseModel *contact = [_ary objectAtIndex:indexPath.row];
    DTModel *model = [[DTModel alloc]init];
    model.uid = contact.uid;
    UIStoryboard *customerStoryboard = [UIStoryboard storyboardWithName:@"MS"
                                                                 bundle:[NSBundle mainBundle]];
    FriendDetailsMainVC *searchResultDetailController = [customerStoryboard instantiateViewControllerWithIdentifier:@"FriendDetailsMainVC"];
    searchResultDetailController.model = model;
    [self.navigationController pushViewController:searchResultDetailController animated:YES];
}
　　
- (IBAction)backAction:(UIBarButtonItem *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
